package cn.edu.scau.cmi.qiuyaohua.client;

import cn.edu.scau.cmi.qiuyaohua.interprogramming.Primier;
import javafx.application.Application;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

public class CreatePremier extends Application {

    public static void main(String[] args) {
        launch(args);
    }
    Label label1=new Label("premier:");
    Label label2=new Label("current premier:");
    TextField textField1=new TextField();
    TextField textField3=new TextField("无主席");
    TextField textField2=new TextField("请创建主席");
    public static int i=0;
    @Override
    public void start(Stage primaryStage) {
        GridPane pane=new GridPane();
        pane.setAlignment(Pos.CENTER);
        pane.setPadding(new Insets(11.5,12.5,20.5,14.5));
        pane.setHgap(5.5);
        pane.setVgap(5.5);

        pane.add(label1,0,0);
        pane.add(label2,0,2);
        pane.add(textField1,1,0);
        pane.add(textField2,1,1);
        pane.add(textField3,1,2);
        Button btAdd=new Button("Add Name");
        pane.add(btAdd,1,3);
        GridPane.setHalignment(btAdd, HPos.RIGHT);

        Scene scene=new Scene(pane);
        primaryStage.setTitle("our Premier");
        primaryStage.setScene(scene);
        primaryStage.show();


        btAdd.setOnAction(event -> {
            if(textField1.getText().equals("")){
                textField2.setText("不可以为空白字符");
            }
            else if(i<1) {
                Primier p1 = new Primier(textField1.getText());
                textField2.setText("Create Success!");
                textField3.setText(p1.getName());
                i++;
                System.out.println(p1.getName());
            }else{
                textField2.setText("Not use!");
            }
        });

    }
}
